#pragma once
#include <time.h>
#include "../lib3dw/Scene.h"
#include "Board.h"
#include "Player.h"
#include "GameRound.h"
#include "StatusBar.h"
#include "GameTurnResult.h"

using namespace lib3dw;

namespace Dicewars
{
	class Game
	{
		public:
			Game(Scene* newScene);
			~Game();
			void Join(Player* newPlayer);
			void AddBoard(Board* gameBoard);
			void AddStatusBar(StatusBar* bar);
			void Start();
			void Update(double secondsPassed);
			void ChangePlayer();
			void CancelRound();
			void FinishRound();
			void PerformTurn(BoardTile* startTile, BoardTile* endTile);
			void PerformAITurn();
			Player* GetActivePlayer();
			
		private:
			int lastMoveTime;
			Scene* scene;
			Board* board;
			Player* activePlayer;
			GameRound* currentRound;
			StatusBar* statusBar;
			long lastUpdate;
			std::vector<Player*> players;
			std::vector<Player*>::const_iterator playersIterator;
			std::vector<GameTurnResult*> turnResults;
			std::vector<GameTurnResult*>::const_iterator turnResultsIterator;
			std::vector<Vector4> GetAllowedTurns();
	};
}